﻿
/*
 * Copyright (C) Han Wei
 */


using BSvr.Model;
using System.Data;
using System.Collections.Generic;


namespace BSvr.PluginAPI
{
    /// <summary>
    /// 业务插件接口
    /// </summary>
    public interface IPlugin
    {
        /// <summary>
        /// 插件编号
        /// </summary>
        string PluginNo { get; set; }

        /// <summary>
        /// 插件工作目录
        /// </summary>
        string CurrentDirectory { get; set; }

        /// <summary>
        /// 插件介绍
        /// </summary>
        string Information { get;}

        /// <summary>
        /// 是否在运行
        /// </summary>
        bool IsRunning { get;}

        /// <summary>
        /// 业务命令执行方法
        /// </summary>
        /// <param name="cmd">命令</param>
        /// <param name="cmdarg">命令参数列表</param>
        /// <returns>命令执行结果{true,业务定}{false,失败原因}</returns>
        /// <remarks>
        /// 失败原因格式
        /// <?xml version="1.0"?><error><code>错误编码</code><content>错误说明</content></error>
        /// </remarks>
        /// <exception cref="Exception">未定义异常</exception>
        OpRst<string> Excute(string cmd, List<string> cmdarg);

        /// <summary>
        /// 业务查询方法
        /// </summary>
        /// <param name="query">查询命令</param>
        /// <param name="queryarg">查询参数列表</param>
        /// <returns>查询结果以xml表示{true,结果}{false,失败原因}</returns>
        /// <remarks>
        /// 失败原因格式
        /// <?xml version="1.0"?><error><code>错误编码</code><content>错误说明</content></error>
        /// </remarks>
        /// <exception cref="Exception">未定义异常</exception>
        OpRst<string> Query(string query, List<string> queryarg);

        /// <summary>
        /// 控制命令执行方法，执行相关命令，并以规定的格式返回
        /// </summary>
        /// <param name="cmd">控制命令</param>
        /// <param name="cmdarg">命令参数列表</param>
        /// <returns>命令执行结果{true,表}{false,失败表}</returns>
        /// <remarks>
        /// 失败表格式
        /// <code>错误编码</code><content>错误说明</content>
        /// </remarks>
        /// <exception cref="Exception">未定义异常</exception>
        OpRst<DataTable> ExcuteConsole(string cmd, List<string> cmdarg);

        /// <summary>
        /// 业务插件初始化
        /// </summary>
        /// <param name="pluginno">插件编号</param>
        /// <param name="currentDir">当前目录</param>
        void Init(string pluginno, string currentDir);

        /// <summary>
        /// 业务插件启动方法
        /// </summary>
        /// <returns>{true,""}{false,失败原因}</returns>
        /// <exception cref="PluginStartException">插件启动时异常</exception>
        OpRst<string> Start();

        /// <summary>
        /// 业务插件停止方法
        /// </summary>
        /// <returns>{true,""}{false,失败原因}</returns>
        /// <remarks>
        /// 失败原因的格式
        /// <?xml version="1.0"?><error><code>错误编码</code><content>错误说明</content></error>
        /// </remarks>
        /// <exception cref="Exception">其他异常</exception>
        OpRst<string> End();

    }
}
